package com.ikun.usercenter.exception;

import com.ikun.usercenter.common.ErrorCode;

/**
 * 自定义异常
 * @author 顾琴
 */
public class BusinessException extends RuntimeException{
    //运行时异常我们可以不用在代码中通过throws 或者 try ... catch 来显示的捕获异常

    private final int code;

    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }
    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode,String description) {
        super(errorCode.getMsg());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
